﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebBanThuoc.DAO;
using WebBanThuoc.DTO;
using WebBanThuoc.Server;

namespace WebBanThuoc
{
    public partial class CTSanPham : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Session.Remove("tongSoTrang");
                getData();
            }
        }
        public void getData()
        {
            IServerWeb sw = new ServerWeb();
            SanPham_DAO daoSP = new SanPham_DAO(sw.Connection);

            string maSanPham = "";
            if (Request.Params["maSanPham"] != null)
                maSanPham = Request.Params["maSanPham"].ToString();
            Session.Add("maSanPham", maSanPham);
            SanPham sp = daoSP.getByKey(maSanPham);
            Session.Add("sp", sp);
            NhaSanXuat_DAO daoNSX = new NhaSanXuat_DAO(sw.Connection);
            NhaSanXuat nsx = daoNSX.getByKey(sp.MaNhaSanXuat);
            Session.Add("nsx", nsx);

            //listHinh
            HinhAnh_DAO daoHinh = new HinhAnh_DAO(sw.Connection);
            List<HinhAnh> listHinh = daoHinh.getListByKey(maSanPham);
            Session.Add("listHinh", listHinh);

            sw.closeConnection();
        }
        /* protected void bt_muaHang_Click(object sender, EventArgs e)
         {
             string maSanPham = Session["maSanPham"].ToString();
             Response.Redirect("GioHang.aspx?maSanPham="+maSanPham);
         } */
    }
}
